<style lang="less" scoped>
.signOrder {
  .prog-wrap {
    padding: 0;
    div {
      &:first-of-type {
        padding-top: 0.1rem;
      }
      &:last-of-type {
        padding-bottom: 0.1rem;
      }
    }
    p,
    label {
      font-size: 14px;
      padding: 0 0.2rem;
    }
    .BillNo {
      font-size: 16px;
      padding-top: 0.2rem;
      padding-bottom: 0.2rem;
      border-bottom: 1px solid #ccc;
    }
    .displayflex {
      label {
        color: #888;
      }
      p {
        color: #888;
        &:last-child {
          text-align: right;
        }
      }
    }
  }
  .call {
    color: #888;
  }
  .form-wrap-row.diff {
    padding-top: 0;
    padding-bottom: 0;
  }
}
</style>

<template>
  <div class="signOrder">
    <div class="prog-wrap mb30">
      <p class="BillNo">业务单号：{{todolist.billno}}</p>
      <div>
        <div class="displayflex">
          <label>制单时间：</label>
          <p class="flex1">{{todolist.billdate}}</p>
        </div>
        <div class="displayflex">
          <label>供应单位：</label>
          <p class="flex1">{{todolist.suppliername}}</p>
        </div>
        <div class="displayflex">
          <label>业务员：</label>
          <p class="flex1">{{todolist.mkstaffname}}</p>
        </div>
        <div class="displayflex">
          <p class="flex1">交货数：</p>
          <p class="flex1">
            <em class="org">{{CountGoods}}</em>
          </p>
        </div>
      </div>
    </div>

    <uploader class="mb30" :title="'回执单上传'" :img-list="imgList" :max="maxPic"></uploader>

    <!-- <div class="form-switch mb30">
      <x-switch prevent-default :title="'是否有差异'" v-model="hasDiff" @on-click="hasDiff = !hasDiff"></x-switch>
    </div> -->

    <div class="form-wrap mb30">
      <div class="form-wrap-row">
        <div class="line displayflex">
          <div class="label">备注</div>
          <div class="ipt flex1">
            <x-textarea :max="200" :placeholder="'请输入备注信息（最多200字符）'" :autosize="true" v-model="todolist.memo"></x-textarea>
          </div>
        </div>
      </div>
    </div>

    <div class="detail-bottom displayflex">
      <span>
        共计：<em class="red">{{TotalCounts}}</em>个商品
      </span>
      <div class="flex1 btn-grp">
        <div @click="$router.push({path: '/index'})" class="btn gray">取消</div>
        <div @click="Save()" class="btn">收货完成</div>
      </div>
    </div>
  </div>
</template>

<script>
import uploader from "@/components/share/imageUploader/imageUploader.vue";
export default {
  components: {
    uploader
  },
  name: "",
  data() {
    return {
      hasDiff: false,
      //图片
      imgList: [],
      maxPic: 9,
      diffReason: [
        [
          "订单取消",
          "销售取消",
          "运送损毁",
          "近效期/过期",
          "数量不足",
          "地址错误",
          "医生不在",
          "质量问题",
          "中途遗失",
          "其它"
        ]
      ],
      diffValue: [],
      todolist: [],
      todoDetail: [],
      request: {
        wvbillno: "",
        searchWord: ""
      },
      CountGoods: 0,
      TotalCounts: 0
    };
  },
  watch: {
    hasDiff(n, o) {
      if (!this.hasDiff) this.diffValue = [];
    }
  },
  computed: {},
  created() {
    this.getData();
  },
  mounted() {},
  methods: {
    getData: function() {
      var self = this;
      self.TotalCounts = self.$route.query.pkgs;
      self.request.wvbillno = self.$route.query.BillNo;
      this.Ajax.post("wxh/order/getOrderDetailList", self.request).then(
        resp => {
          if (resp.errorCode == 0) {
            this.todolist = resp.data.bill;
            this.todoDetail = resp.data.billdetaillist;
            this.todoDetail.forEach(item => {
              item.Signed = false;
              self.CountGoods += item.purchaser_poqty;
            });
          } else {
            this.Toast({
              message: resp.message || "操作异常，请稍后重试"
            });
          }
        }
      );
    },
    Save() {
      var self = this;
      var request={
        	mvbillno:self.$route.query.BillNo,
        	signpict:JSON.stringify(self.imgList)
        };
      this.Ajax.post("wxh/order/saveMvOrder", request).then(resp => {
        if (resp.errorCode == 0) {
          this.Toast({
            message: resp.message || "签收完成！"
          })
          this.$router.replace({
            path: "/index"
          });
        } else {
          this.Toast({
            message: resp.message || "操作异常，请稍后重试"
          });
        }
      });
    }
  }
};
</script>